﻿using Medicalsystem.MCP.FormDesigner.Define;
using Medicalsystem.MCP.FormDesigner.MyControls;

namespace Medicalsystem.MCP.FormDesigner.Common
{
    /// <summary>
    /// 控件
    /// </summary>
    public class ControlBuilder
    {
        /// <summary>
        /// 创建控件实例
        /// </summary>
        /// <param name="controlName">控件名称</param>
        /// <param name="state">状态</param>
        /// <returns></returns>
        public static System.Windows.Forms.Control ControlNew(string assName, string controlName, Model model, EDesignModeState state)
        {
            if (string.IsNullOrEmpty(controlName) || controlName.Trim().Length == 0)
            {
                return null;
            }
            try
            {
                return (System.Windows.Forms.Control)CacheManager.Instance.GetObjFrom(assName, controlName, model, state);
            }
            catch
            {
                return null;
            }


        }
    }
}